<?php

declare(strict_types=1);

namespace App\Model;

use Qbhy\HyperfAuth\Authenticatable;

/**
 * @property int $uid 
 * @property string $username 
 * @property string $head_img 
 * @property string $password 
 * @property string $real_name 
 * @property string $last_ip 
 * @property int $last_time 
 * @property int $login_count 
 * @property int $is_del 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property int $status 
 * @property string $role_id 
 * @property int $is_admin 
 */
class SysUser extends Model implements Authenticatable
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'sys_user';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = [];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['uid' => 'integer', 'last_time' => 'datetime', 'login_count' => 'integer', 'status' => 'integer', 'is_admin' => 'integer','created_at' => 'datetime', 'updated_at' => 'datetime'];
    
    public function getId()
    {
        return $this->uid;
    }

    public static function retrieveById($key): ?Authenticatable
    {
        return self::query()->where('uid',$key)->first();
    }
}
